'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	const {searchVal} = event

	//聚合，筛选
	const list = await db.collection('article').aggregate().
	match({
		title: new RegExp(searchVal) // 模糊查询
	}).
	project({
		content:0
	})
	.end()
	
	//返回数据给客户端
	return {
		code: 200,
		data:list.data,
		msg: '数据获取成功'
	}
};
